<template>
	<view class="body">
		<view class="detail" v-for="item in Detail" :key="item.JFDNO">
			<view class="detail-item">
				<view class="detail-title">
					<text>流水号</text>
				</view>
				<view class="detail-info">
					<text>{{item.JFDNO}}</text>
				</view>
			</view>
			<view class="detail-item">
				<view class="detail-title">
					<text>缴费单ID</text>
				</view>
				<view class="detail-info">
					<text>{{item.JFD_ID}}</text>
				</view>
			</view>
			<view class="detail-item">
				<view class="detail-title">
					<text>班级名称</text>
				</view>
				<view class="detail-info">
					<text>{{item.CLASSNAME}}</text>
				</view>
			</view>
			<view class="detail-item">
				<view class="detail-title">
					<text>学生姓名</text>
				</view>
				<view class="detail-info">
					<text>{{item.STUDENTNAME}}</text>
				</view>
			</view>
			<view class="detail-item">
				<view class="detail-title">
					<text>学号</text>
				</view>
				<view class="detail-info">
					<text>{{item.STUDENTNO}}</text>
				</view>
			</view>
			<view class="detail-item">
				<view class="detail-title">
					<text>状态</text>
				</view>
				<view class="detail-info">
					<text>{{item.STATENR}}</text>
				</view>
			</view>
		</view>
		<view class="isopinion">
			<view class="isopinion-title">
				<text>审核意见</text>
			</view>
			<view class="isopinion-info">
				<radio-group @change="onSelectStatus">
					<view class="">
						<view>
							<label class="text-sm">通过</label>
							<radio
									:class="['radio','blue',curSelectStatus === '1' ? 'checked' : '']"
									:checked="curSelectStatus === '1'"
									value="1"
									style="transform: scale(0.8)"
							>
							</radio>
				
							<label class="text-sm">不通过</label>
							<radio
									:class="['radio','blue',curSelectStatus === '2' ? 'checked' : '']"
									:checked="curSelectStatus === '2'"
									value="2"
									style="transform: scale(0.8)"
							>
							</radio>
						</view>
					</view>
				</radio-group>
			</view>
		</view>
	</view>
	<view class="submit-button">
		<button @click="handleSubmit">提交审核</button>
	</view>
</template>

<script lang="ts" setup>
	import {onLoad} from "@dcloudio/uni-app";
	import {onMounted,reactive,ref} from "vue"
	import {useRefundAuditListDetail} from "./useTkshDetail"
	import { RefundAudit} from "../../api/refundaudit"
	const { initRefundAuditListDetail, initRefundAudit, initRefundAuditLast} = useRefundAuditListDetail()
	const curSelectStatus = ref<'1' | '2'>('1')
	let Detail = ref<any>([])
	let JFD_ID = ref<any>("")
	let SFJE = ref<any>("")
	function onSelectStatus(e){
		curSelectStatus.value = e.detail.value
	}
	function handleSubmit(){
		uni.showModal({
			title: '提示消息',
			content: '您确定提交审核吗',
			success: res => {
				if (res.confirm) { //确认提交
					initRefundAudit({
						JFD_ID:JFD_ID.value,
						SH_FLAG:curSelectStatus.value
					})
					.then(res=>{
						if (res.ERROR[0].errcode == '0'){
							 uni.showToast({
									 title: res.RET[0].RET,
									 icon: 'none',
									 mask: true
							 })
							 if(res.COUNT[0].total_fee!=null&&res.COUNT[0].order_code!=null&&res.COUNT[0].transaction_id!=null){ //判断返回值是否有.total_fee，transaction_id，order_code
								 initRefundAuditLast({  //提交审核退款信息
								 	 total_fee:res.COUNT[0].total_fee,
								 	 order_code:res.COUNT[0].order_code,
								 	 transaction_id:res.COUNT[0].transaction_id
								 }) 
							 }else{
								 setTimeout(()=>{
								 	uni.navigateBack({
								 		delta:1
								 	})
								 },500)
							 }
						}else {
								uni.showToast({
									title: res.ERROR[0].error,
									icon: 'none',
									mask: true
								})
						}
					})
				} 
			},
			fail: () => {},
			complete: () => {}
		});
	}
	
	onLoad(async (option:any)=>{
		JFD_ID.value = option.JFD_ID
		SFJE.value = option.SFJE
		initRefundAuditListDetail(JFD_ID.value)
		.then(res=>{
			Detail.value = res.DAT
		})
	})
</script>

<style lang="scss">
	.body{
		width: 100%;
		height: 100%;
		background-color: white;
	}
	.detail{
		.detail-item{
			padding: 0 32rpx 0 32rpx;
			border-bottom: 4rpx #F7F8FC solid;
			width: 100%;
			height: 110rpx;
			display: flex;
			align-items: center;
			.detail-title{
				margin-right:32rpx ;
			}
		}
	}
	.isopinion{
		padding: 0 32rpx 0 32rpx;
		border-bottom: 4rpx #F7F8FC solid;
		width: 100%;
		height: 110rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		.isopinion-title{
			margin-right:32rpx ;
		}
	}
	.submit-button{
		position: absolute;
		bottom: 0;
		button{
			background-color: #FF5918;
			color: white;
			width: 750rpx;
			border-radius: 0;
		}
	}
</style>